package cn.com.twoke.get_xml_data.service.impl;

import cn.com.twoke.get_xml_data.entity.TestPlanReport;
import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;

import java.io.File;

public class JsonGetXmlDataHandler extends LogGetXmlDataHandler{

    private final String outputDir;
    public JsonGetXmlDataHandler(String outputDir) {
        super(null);
        this.outputDir = outputDir + File.separator + "json";
    }

    @Override
    protected void handle(String fileNo, File file, TestPlanReport testPlanReport) {
        super.handle(fileNo, file, testPlanReport);
        String data = JSONUtil.toJsonPrettyStr(testPlanReport);
        FileUtil.writeString(data, outputDir + File.separator + fileNo + "_" + file.getName() + ".json",
                "utf-8");
    }
}
